with Ada.Text_IO ; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Temperature is
   -- declaration
   type Day is(Monday, Tuesday, Wenesday, Thursday, Friday, Saturday, Sunday);
   type Temp_Board is array( Day ) of Integer;
   Temp : Temp_Board;

   -- init
   procedure Init is
   begin
      for I in Temp'Range loop
         Temp(I) := 1;
      end loop;
   end Init;

   -- saisie _ affiche
   procedure Saisie_Affiche is
   begin
      for I in Temp'Range loop
         Put("Temperature du jour :");
         Put(Day'Image(I));
         Put("      ");
         Get(Temp(I));
         New_Line;
      end loop;

      for I in Temp'Range loop
         Put(Integer'Image(Temp(I)));
         Put(" |` ");
      end loop;
      New_Line;
   end Saisie_Affiche;

   -- nb jour ou il a gele
   procedure Nb_Freeze is
      Nb :Integer := 0;
   begin
      for I in Temp'Range loop
         if Temp(I) <= 0 then
            Nb := Nb + 1;
         end if;
      end loop;
      Put("il a gelé ");
      Put(Integer'Image(Nb));
      Put(" jours!");
      New_Line;
   end Nb_Freeze;

   -- have freeze
   procedure Have_Freeze is
      F :Boolean := False ;
   begin
      for I in Temp'Range loop
         if Temp(I) <= 0 then
            F := True;
            exit;
         end if;
      end loop;
      if F = True then
         Put_Line("il a gelé");
      else
         Put_Line("il n'a pas gelé");
      end if ;

   end Have_Freeze;

   -- average temp
   procedure Average is
      A : Float := 0.00;
   begin
      for I in Temp'Range loop
         A := A + Float(Temp(I));
      end loop;
      A := A / 7.00;
      Put("il a fait ");
      Put(Float'Image(A));
      Put(" °C en moyenne cette semaine .");
      New_Line;
   end Average;

   -- max heat
   procedure Max_Heat is
      Max : Integer := -1000;
   begin
      for I in Temp'Range loop
         if Temp(I) > Max then
            Max := Temp(I);
         end if;
      end loop;
      Put("il a fait ");
      Put(Integer'Image(max));
      Put(" °C au maximun cette semaine .");
      New_Line;
   end Max_Heat;



begin
   Init;
   Saisie_Affiche;
   Nb_Freeze;
   Have_Freeze;
   Average;
   Max_Heat;

end Temperature;
